package bean;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import dao.ProvaDAO;
import dao.QuestoesDAO;


import model.Prova;
import model.Questoes;

/**
 * Session Bean implementation class QuestoesEJB
 */
@Stateless
public class QuestoesEJB implements QuestoesEJBLocal {

	@PersistenceContext(unitName="galeradoconcurso")
	private EntityManager em;
    /**
     * Default constructor. 
     */
    public QuestoesEJB() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void cadastrarQuestao(Questoes q) {
		QuestoesDAO dao = new QuestoesDAO(em);
    	dao.adicionarQuestoesDAO(q);
		
	}

	@Override
	public List<Questoes> listarQuestoes(Prova prova) {
		ProvaDAO dao = new ProvaDAO(em);    	
		return dao.buscar(prova.getId()).getQuestoes();		
	}

	@Override
	public void removerQuestao(Questoes questao) {
		QuestoesDAO dao = new QuestoesDAO(em);
		dao.remove(questao);
	}

}
